package com.ll.config;

import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@Configuration
public class EmailServerConfiguration implements EnvironmentAware {

	private static RelaxedPropertyResolver propertyResolver;

	public int getSize(String key) {
		return Integer.valueOf(propertyResolver.getProperty(key));
	}

	public int getTaskQueueSize(String key) {
		return Integer.valueOf(propertyResolver.getProperty(key));
	}

	public long getScheduledTime(String key) {
		return Long.valueOf(propertyResolver.getProperty(key));
	}

	public String getShopId(String key) {
		return propertyResolver.getProperty(key);
	}

	@Override
	public void setEnvironment(Environment environment) {
		EmailServerConfiguration.propertyResolver = new RelaxedPropertyResolver(environment, "emailServer.");
	}

}
